﻿using System;
using System.Windows;
using System.Windows.Controls;
using SilverlightClientApp.viewModel;

namespace SilverlightClientApp
{
	public partial class MainPage
	{
		public MainPage()
		{
			// Required to initialize variables
			InitializeComponent();
		    DataContext = new ViewModel();
		}

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var button = sender as Button;
            if (button == null)
            {
                throw new ArgumentException("Object is not a Button!");
            }
            int argument;
            if (button == btn1)
            {
                argument = 1;
            }
            else if (button == btn2)
            {
                argument = 2;
            }
            else if (button == btn3)
            {
                argument = 3;
            }
            else
            {
                argument = 4;
            }
            ((ViewModel)DataContext).GetData(argument);
        }
	}
}